package top.fzqblog.firstapp;

import android.app.DatePickerDialog;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.DatePicker;
import android.widget.TimePicker;

/**
 * Created by 抽离 on 2017/8/16 0016.
 */

public class DateTimePickTest extends AppCompatActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.datetimepickertest);
        DatePicker datePicker = (DatePicker) findViewById(R.id.dp);
        TimePicker timePicker = (TimePicker) findViewById(R.id.tp);
        timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
            @Override
            public void onTimeChanged(TimePicker timePicker, int hourOfDay, int minutes) {
                setTitle(hourOfDay + "时" + minutes + "分");
            }
        });

        new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker datePicker, int year, int month, int day) {
                setTitle(year + "年" + month + "月" + day + "日");
            }
        }, 2017, 8, 16).show();

    }


}
